<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>拍照demo</title>
	<style type="text/css">
	
	  @import url("./css/new_file.css");
	
	</style>
    <script type="text/javascript">
    	
   		// 扩展API加载完毕后调用onPlusReady回调函数 
   		document.addEventListener( "plusready", plusReady, false );
   		// 扩展API加载完毕，现在可以正常调用扩展API 
   	
		
		function plusReady(){  
		   cmr = plus.camera.getCamera(); //全局变量
		   
			
			
		   console.log("API插件加载完毕！");
		   plus.nativeUI.toast("房屋拍照初始化完毕");
		   
		}
		
		// var file_path = '/storage/emulated/0/Pictures/';
		
		var file_path;
		
		
		

		// 拍照
		function captureImage(){
			var res = cmr.supportedImageResolutions[0];
			var fmt = cmr.supportedImageFormats[0];
			console.log("Resolution: "+res+", Format: "+fmt);
			
			cmr.captureImage( function( path ){
			
					
					plus.nativeUI.toast("拍摄成功！" + path);  
				},
				function( error ) {
					alert("拍照取消");
					// alert( "拍照失败: " + error.message );
				},
				{resolution:res,format:fmt,filename:file_path}
				//官方文档:可设置具体文件名（如"_doc/camera/a.jpg"）
			);
		}
		
		function classify(){
			var time_info = Date.parse(new Date()).toString();
			var classify_target = prompt("请输入分组名称", "张连臣");
			if (classify_target != null) {
				file_path = '/storage/emulated/0/Pictures/' + classify_target+time_info+'.jpg';
				window.alert("设置成功！");
			    document.getElementById("demo").innerHTML = "当前分组:" + classify_target;
			}
			
		}
	
   		
    </script>
</head>
<body>
	<p id="demo">房屋拍照</p><br>
	<button class='main_button' onclick=captureImage()>点击拍照</button>
	<br><br>
	<button class='main_button' onclick=classify()>选择分组</button>
</body>
</html>
